<%@ page language="java" import="java.util.*" pageEncoding="utf-8"  %>
<%@ page import="java.sql.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 	 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
	<link href="style/authority/basic_layout.css" rel="stylesheet" type="text/css">
	<link href="style/authority/common_style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="scripts/authority/commonAll.js"></script>
	<script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
	<script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	<link rel="stylesheet" type="text/css" href="style/authority/jquery.fancybox-1.3.4.css" media="screen"></link>
	<script type="text/javascript" src="scripts/artDialog/artDialog.js?skin=default"></script>
    <base href="<%=basePath%>">
    
    <title>注册</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="scripts/Myscripts/alpha_add.js"></script>
<script language="javascript" type="text/javascript" >

function checkName(){
var username=document.form1.user_name.value;
var flag=true;
if(username.length==0)
{
	flag=false;
	document.getElementById("user_namel").style.color="red";
	document.getElementById("user_namel").style.fontSize="12px";
	document.getElementById("user_namel").innerText="用户名不可为空！";
	return flag;
	}
	else if(!((username.charAt(0)>='a'&&username.charAt(0)<='z')||(username.charAt(0)>='A'&&username.charAt(0)<='Z')))
	{
		flag=false;
		document.getElementById("user_namel").style.color="red";
		document.getElementById("user_namel").style.fontSize="12px";
		document.getElementById("user_namel").innerText="用户名必须以字母开头！";
		return flag;
	}
for(var i=0;i<username.length;i++)
{
	if((username.charAt(i)>='a'&&username.charAt(i)<='z')||(username.charAt(i)>='A'&&username.charAt(i)<='Z')||(username.charAt(i)>='0'&&username.charAt(i)<='9')){
	}else{
		flag=false;
		break;
	}
}

if(flag){
document.getElementById("user_namel").style.color="green";
document.getElementById("user_namel").style.fontSize="12";
document.getElementById("user_namel").innerText="√";
return true;
}else{
	document.getElementById("user_namel").style.color="red";
	document.getElementById("user_namel").style.fontSize="12px";
	document.getElementById("user_namel").innerText="用户名只可含有字母或数字！";
	return false;
}
}


function checkPassword(){
	var pass=form1.password.value;
	if(pass.length<6){
	document.getElementById("passwordl").style.color="red";
	document.getElementById("passwordl").style.fontSize="12px";
	document.getElementById("passwordl").innerText="密码长度至少6位";
	return false;
	}else{
	document.getElementById("passwordl").style.color="green";
	document.getElementById("passwordl").style.fontSize="12px";
	document.getElementById("passwordl").innerText="√";
	return true;
	}
	}

	function checkRepassword(){
	var pass=form1.password.value;
	var rpass=form1.repassword.value;
	if(pass==rpass){
	document.getElementById("repasswordl").style.color="green";
	document.getElementById("repasswordl").style.fontSize="12px";
	document.getElementById("repasswordl").innerText="√";
	return true;
	}else{
	document.getElementById("repasswordl").style.color="red";
	document.getElementById("repasswordl").style.fontSize="12px";
	document.getElementById("repasswordl").innerText="与原密码不符！";
	return false;
	}
	}



	function checkIdCard(){
		var idcard=document.form1.id_card.value;
		var pattern=/^\d{15}$|^\d{18}&|^\d{17}[xX]$/;
		
		var flag=false;  
		if(pattern.test(idcard)){
		flag=true;
		}else{
		flag=false;
		}
		if(flag){
		document.getElementById("id_cardl").style.color="green";
		document.getElementById("id_cardl").style.fontSize="12";
		document.getElementById("id_cardl").innerText="√";
		return true;
		}else{
		document.getElementById("id_cardl").style.color="red";
		document.getElementById("id_cardl").style.fontSize="12";
		document.getElementById("id_cardl").innerText="身份证非法！";
		return false;
		}
		}
		
	function checkCellphone(){
	var mobile=form1.cellphone.value;
	var pattern=/^\d{11}$/;
	if(!pattern.test(mobile))
	{
		document.getElementById("cellphonel").style.color="red";
		document.getElementById("cellphonel").style.fontSize="12px";
		document.getElementById("cellphonel").innerText="移动电话应为11位数字！";
	}else{
		document.getElementById("cellphonel").style.color="green";
		document.getElementById("cellphonel").style.fontSize="12px";
		document.getElementById("cellphonel").innerText="√";
	}
	}	
		
	function checkTel(){
	var tel=form1.tel.value;
	var pattern=/^\d{3}-\d{8}|d{4}-\d{7}$/;
	if(!pattern.test(tel))
	{
		document.getElementById("tell").style.color="red";
		document.getElementById("tell").style.fontSize="12px";
		document.getElementById("tell").innerText="格式错误！";
	}else{
		document.getElementById("tell").style.color="green";
		document.getElementById("tell").style.fontSize="12px";
		document.getElementById("tell").innerText="√";
	}
	}	
	
	
	function checkMail(){
	var email=form1.email.value;
	if(email.indexOf("@")==-1||email.indexOf(".")==-1){
	document.getElementById("emaill").style.color="red";
	document.getElementById("emaill").style.fontSize="12px";
	document.getElementById("emaill").innerText="邮箱格式错误！";
	return false;
	}else{
	document.getElementById("emaill").style.color="green";
	document.getElementById("emaill").style.fontSize="12px";
	document.getElementById("emaill").innerText="√";
	return true;
	}
	}

	function checkAddr(){
		var addr=form1.address.value;
		if(addr!=""){
			document.getElementById("addressl").style.color="green";
			document.getElementById("addressl").style.fontSize="12px";
			document.getElementById("addressl").innerText="√";
		}else{
		document.getElementById("addressl").style.color="red";
		document.getElementById("addressl").style.fontSize="12px";
		document.getElementById("addressl").innerText="联系地址不可为空！";
	}
	}

	function checkZipcode(){
		var zipcode=document.form1.zipcode.value;
		var pattern=/^\d{6}$/;
		var flag=false;
		if(pattern.test(zipcode)){
			flag=true;
			}else{
			flag=false;
			}
		if(flag){
		document.getElementById("zipcodel").style.color="green";
		document.getElementById("zipcodel").style.fontSize="12px";
		document.getElementById("zipcodel").innerHTML="√";
		return true;
		}else{
		document.getElementById("zipcodel").style.color="red";
		document.getElementById("zipcodel").style.fontSize="12px";
		document.getElementById("zipcodel").innerText="邮编应为6位数字！";
		return false;
		}
		}



	function checkAll(){
		if(checkName()&&checkPassword()&&checkRepass()&&checkMail()&&checkAddress()&&checkIdCard()&&checkZipcode()&&checkTel()&&checkCellphone()){
		return true;
		}else{
		return false;
		}
		} 

</script>
  </head>
  

   
<body> 

<form name="form1" action="servlet/Registerservlet?type=insert" method="post" onSubmit="return checkAll();"> 
<div id = "add_alpha_id">
<div id="container">	
		<div class="ui_content">
				<div class="ui_text_indent">
					<div id="box_border">
						<div id="box_top">新用户注册</div>
						<div id="box_bottom">							
						</div>
					</div>
				</div>
			</div>		
			<div class="ui_content">
				<div class="ui_tb">
<table class="table" width="100%"> 
<tr> 
<th >用户名：</th> 
<td><input class="ui_input_txt02" type="text" id="user_name" name="user_name"  onblur="checkName()" ></td> 
<td><div id="user_namel">&nbsp;</div></td> 

<th>真实姓名：</th> 
<td><input class="ui_input_txt02" type="text" id="user_nick" name="user_nick"></td> 
<td ><div id="user_nickl">&nbsp;</div></td> 
</tr> 
<tr> 
<th>密&nbsp;&nbsp;&nbsp;&nbsp;码：</th> 
<td><input class="ui_input_txt02" type="password" id="password" name="password"  onblur="checkPassword()"></td> 
<td ><div id="passwordl">&nbsp;</div></td> 

<th>确认密码：</th> 
<td><input class="ui_input_txt02" type="password" id="repassword" name="repassword" onBlur="checkRepassword();"></td> 
<td><div id="repasswordl">&nbsp;</div></td> 
</tr> 


<tr> 
<th  >身份证号：</th> 
<td><input class="ui_input_txt02" type="text" id="id_card" name="id_card" maxlength="18"onBlur="checkIdCard();"></td> 
<td ><div id="id_cardl">&nbsp;</div></td> 

<th >工作单位：</th> 
<td><input class="ui_input_txt02" type="text" name="company"></td> 
<td><div id="companyl">&nbsp;</div></td> 
</tr> 

<tr> 
<th >移动电话：</th> 
<td><input class="ui_input_txt02" type="text" id="cellphone" name="cellphone" maxlength="11"onBlur="checkCellphone();"></td> 
<td ><div id="cellphonel">&nbsp;</div></td> 

<th>座&nbsp;&nbsp;&nbsp;&nbsp;机：</th> 
<td><input class="ui_input_txt02" type="text" id="tel" name="tel" onBlur="checkTel();"></td> 
<td><div id="tell">&nbsp;</div></td> 
</tr> 

<tr> 
<th>邮&nbsp;&nbsp;&nbsp;&nbsp;箱：</th> 
<td><input class="ui_input_txt02" type="text" id="email" name="email" onBlur="checkMail();"></td> 
<td><div id="emaill">&nbsp;</div></td> 

<th>联系地址：</th> 
<td><input class="ui_input_txt02" type="text" id="address" name="address" onBlur="checkAddress();"></td> 
<td ><div id="addressl">&nbsp;</div></td> 
</tr> 


<tr> 
<th >邮&nbsp;&nbsp;&nbsp;&nbsp;编：</th> 
<td><input class="ui_input_txt02" type="text" id="zipcode" name="zipcode" maxlength="6"onBlur="checkZipcode();"></td> 
<td><div id="zipcodel">&nbsp;</div></td> 

<th></th><td></td><td></td>
</tr> 

<tr> 
<td  colspan="6" align="center"><label>   
   <input class="ui_input_btn01" type="submit" value="提交" onblur="checkAll()"> 
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
   <input class="ui_input_btn01" name="reset" type="reset" value="重置"> 
        </label></td> 
</tr>
</table>
</div>
</div>
</div>
</div>
</form>
<script type="text/javascript">
    var eitem = document.getElementById("add_alpha_id");
    window.onload = add_alpha(eitem);
    </script>
 </body>
</html>
